package com.qujia.station.controller;

import com.github.pagehelper.PageInfo;
import com.qujia.common.core.controller.BaseController;
import com.qujia.common.core.domain.AjaxResult;
import com.qujia.common.utils.SecurityUtils;
import com.qujia.common.utils.poi.ExcelUtil;
import com.qujia.station.domain.vo.EnterpriseAndStationVo;
import com.qujia.station.service.IStationService;
import com.qujia.station.service.ISysUserInviteInfoService;
import com.qujia.system.domain.dto.SysUserInviteInfoDetailResDto;
import com.qujia.system.domain.dto.SysUserInviteInfoResDto;
import com.qujia.system.domain.form.SysUserInviteInfoDetailReqForm;
import com.qujia.system.domain.form.SysUserInviteInfoReqForm;
import com.qujia.system.domain.vo.ResponseVo;
import com.qujia.system.domain.vo.SysUserInviteInfoListResVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(tags = "员工推荐管理")
@RestController
@RequestMapping("/staff/invite")
public class SysUserInviteInfoController extends BaseController {

    @Autowired
    private ISysUserInviteInfoService sysUserInviteInfoService;

    @Autowired
    private IStationService stationService;


    @ApiOperation("生成员工微信动态推荐码")
    @GetMapping("/getQrCode")
    public AjaxResult getQrCode(@ApiParam(value = "员工id", required = true) Long userId) {
        return AjaxResult.success(sysUserInviteInfoService.getUserInviteQrCodeInfo(userId));
    }

    @ApiOperation("查询员工推荐信息列表")
    @GetMapping("/list")
    public AjaxResult list(SysUserInviteInfoReqForm sysUserInviteInfoReqForm) {

        SysUserInviteInfoListResVo resVo = sysUserInviteInfoService.getSysUserInviteInfoListPage(sysUserInviteInfoReqForm);
        return AjaxResult.success(new ResponseVo<>(resVo, new PageInfo(resVo.getUserInviteInfos()).getTotal()));
    }

    @ApiOperation("查询员工推荐的用户信息列表")
    @GetMapping("/detail/list")
    public AjaxResult detailList(SysUserInviteInfoDetailReqForm sysUserInviteInfoDetailReqForm) {
        List<SysUserInviteInfoDetailResDto> resDtos = sysUserInviteInfoService.getSysUserInviteInfoDetailList(sysUserInviteInfoDetailReqForm);
        return AjaxResult.success(new ResponseVo<>(resDtos, new PageInfo(resDtos).getTotal()));
    }

    @ApiOperation("导出员工推荐信息列表")
    @GetMapping("/export")
    public AjaxResult export(SysUserInviteInfoReqForm sysUserInviteInfoReqForm) {
        ExcelUtil<SysUserInviteInfoResDto> util = new ExcelUtil<SysUserInviteInfoResDto>(SysUserInviteInfoResDto.class);
        return util.exportExcel(sysUserInviteInfoService.getSysUserInviteInfoList(sysUserInviteInfoReqForm), "员工推荐信息");
    }

}
